package org.nod.atgm.gameobjects;

import org.nod.atgm.model.PrecompiledObjectManager;

import com.threed.jpct.Object3D;

public abstract class PrecompiledGameObject extends TexturedGameObject {

	@Override
	protected Object3D createObject() {
		Object3D object = createFromPrecompiledObject();
		setupObject(object);
		return object;
	}
	
	protected Object3D createFromPrecompiledObject() {
		Object3D precompiledObject = PrecompiledObjectManager.getInstance().getPrecompiledObject(getId());
		Object3D object = new Object3D(precompiledObject, true);
		object.shareCompiledData(precompiledObject);
		object.compile();
		return object;
	}

	protected abstract String getId();

	protected abstract void setupObject(Object3D object);

}
